package com.qibao.springboot.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;


@Component
@ConfigurationProperties(prefix = "redis")
public class RedisConfig extends CachingConfigurerSupport {
    private Logger logger = LoggerFactory.getLogger(RedisConfig.class);

    private String host;
    private int    port;
    private String password;
    private int    timeout;
    private int    poolMaxTotal;
    private int    poolMaxIdle;
    private int    poolMaxWait;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

//    @Bean
//    public JedisPoolConfig getRedisConfig() {
//        JedisPoolConfig poolConfig = new JedisPoolConfig();
//        return poolConfig;
//    }


//    @Bean
//    public JedisPool getJedisPool() {
//        JedisPoolConfig config = getRedisConfig();
//        JedisPool pool = new JedisPool(config,host,port,timeout);
//        logger.info("init JredisPool ...");
//        return pool;
//    }


//    @Bean
//    public Jedis getJedis() {
//        return getJedisPool().getResource();
//    }
}